 /*******************************************************************************
  * Copyright (c) 2003, 2006 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
  * IBM Corporation - initial API and implementation
  *******************************************************************************/
 package org.eclipse.ui.internal.presentations.r21;

 import java.util.MissingResourceException ;
 import java.util.ResourceBundle ;

 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;

 /**
  * The main plugin class to be used in the desktop.
  */
 public class R21PresentationPlugin extends AbstractUIPlugin {
     //The shared instance.
 private static R21PresentationPlugin plugin;

     //Resource bundle.
 private ResourceBundle resourceBundle;

     /**
      * The constructor.
      */
     public R21PresentationPlugin() {
         super();
         plugin = this;
         try {
             resourceBundle = ResourceBundle
                     .getBundle("org.eclipse.ui.internal.r21presentation.R21lookPluginResources"); //$NON-NLS-1$
 } catch (MissingResourceException x) {
             resourceBundle = null;
         }
     }

     /**
      * Returns the shared instance.
      */
     public static R21PresentationPlugin getDefault() {
         return plugin;
     }

     /**
      * Returns the string from the plugin's resource bundle,
      * or 'key' if not found.
      */
     public static String getResourceString(String key) {
         ResourceBundle bundle = R21PresentationPlugin.getDefault()
                 .getResourceBundle();
         try {
             return (bundle != null) ? bundle.getString(key) : key;
         } catch (MissingResourceException e) {
             return key;
         }
     }

     /**
      * Returns the plugin's resource bundle,
      */
     public ResourceBundle getResourceBundle() {
         return resourceBundle;
     }

     /* (non-Javadoc)
      * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
      */
     public void start(BundleContext context) throws Exception {
         super.start(context);
         R21Colors.startup();
     }

     /* (non-Javadoc)
      * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
      */
     public void stop(BundleContext context) throws Exception {
         super.stop(context);
         R21Colors.shutdown();
     }
 }

